package com.cwnu.onlinemall.service;

import com.cwnu.onlinemall.mapper.MallProductMapper;
import com.cwnu.onlinemall.pojo.MallProduct;
import com.cwnu.onlinemall.pojo.MallSalesrecord;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ProductServiceImpl implements ProductService{
    @Autowired
    MallProductMapper mallProductMapper;
    @Override
    public List<MallProduct>  selectProductAll() {
        return mallProductMapper.selectByExample(null);
    }

    @Override
    public MallProduct selectById(Integer id) {
        MallProduct mallProduct = mallProductMapper.selectByPrimaryKey(id);
        return mallProduct;
    }

    @Override
    public Integer insert(MallProduct mallProduct) {
        int insertRow = mallProductMapper.insertSelective(mallProduct);
        return insertRow;
    }

    @Override
    public Integer deleteById(Integer id) {
        return mallProductMapper.deleteByPrimaryKey(id);
    }

    @Override
    public Integer updateById(MallProduct mallProduct) {
        return mallProductMapper.updateByPrimaryKeySelective(mallProduct);
    }
}
